package com.dlb.andorid.presenter;

import com.dlb.andorid.XAPI;
import com.dlb.andorid.XContract;
import com.dlb.andorid.XPresenter;
import com.dlb.andorid.XServerMsg;
import com.dlb.andorid.bean.MyFav;

import java.util.HashMap;
import java.util.List;

public class CollectPresenter extends XPresenter {

	XContract.ICollectView iView;

	public CollectPresenter(XContract.ICollectView iView) {
		super(iView);
		this.iView = iView;
	}

	public void getFav(int type) {
		mModel.getFav(type);
	}

	public void delFav(long collection_id) {
		mModel.delFav(collection_id);
	}

	public void addFav(long commodity_id, int typex) {
		mModel.addFav(commodity_id, typex);
	}

	@Override
	public void onDataSuccess(int vocational_id, HashMap<String, Object> exData, Object data) {
		super.onDataSuccess(vocational_id, exData, data);


		switch (vocational_id) {

			case XAPI.GET_FAV_VOCATIONAL_ID:
				iView.getFavSuccess(((XServerMsg<List<MyFav>>) data).getData(), (Integer) exData.get("type"));
				break;

			case XAPI.ADD_FAV_VOCATIONAL_ID:
				iView.addFavSuccess(((XServerMsg) data));
				break;

			case XAPI.DEL_FAV_VOCATIONAL_ID:
				iView.delFavSuccess(((XServerMsg) data));
				break;

		}


	}
}
